package com.ewanghuiju.app.pay;

import android.content.Context;

import com.ewanghuiju.app.app.Constants;
import com.ewanghuiju.app.model.bean.local.WxPayBean;
import com.ewanghuiju.app.util.LogUtil;
import com.tencent.mm.opensdk.modelpay.PayReq;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

public class WXPay {


    public static void wxPay(Context context, WxPayBean wxPayBean) {
        PayReq req = new PayReq();
        req.appId = wxPayBean.getAppid();
        req.partnerId = wxPayBean.getPartnerid();
        req.prepayId = wxPayBean.getPrepayid();
        req.nonceStr = wxPayBean.getNoncestr();
        req.timeStamp = wxPayBean.getTimestamp();
        req.packageValue = wxPayBean.getPackage1();
        req.sign = wxPayBean.getSign();
        //req.extData			= "购买会员"; // optional
        // 在支付之前，如果应用没有注册到微信，应该先调用IWXMsg.registerApp将应用注册到微信
        IWXAPI api = WXAPIFactory.createWXAPI(context, null);
        api.registerApp(Constants.WX_APPID);
        api.sendReq(req);
    }

}
